package com.gpj.security.service.impl;

import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @className UserDetailsServicea
 * @description
 *   TODO
 * @author GPJ
 * @date 2023/11/7 22:25
 * @version 1.0
 **/
@Service
public class CustomUserDetailsServicea implements UserDetailsService {
	@Override
	public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
		System.out.println("com.gpj.security.service.impl.CustomUserDetailsServicea.loadUserByUsername");

		List<String> permissions = new ArrayList<>();
		permissions.add("user-insert");
		permissions.add("user-delete");
		return User.withUsername(username)
				.password("1234")
				.authorities(permissions.toArray(new String[0]))
				.build();
	}
}
